package app.caihan.scframe.common.loadinghelper

import android.view.LayoutInflater
import android.view.ViewGroup
import app.caihan.scframe.R

/**
 * 默认的界面loading效果
 *
 * @author Seven-C
 * @date 2020/8/3
 */
class LoadingAdapter : LoadingHelper.Adapter<LoadingHelper.ViewHolder> {
    private var height = ViewGroup.LayoutParams.MATCH_PARENT

    constructor()

    constructor(height: Int):this() {
        this.height = height
    }

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): LoadingHelper.ViewHolder {
        return LoadingHelper.ViewHolder(inflater.inflate(R.layout.scframe_layout_loading, parent, false))
    }

    override fun onBindViewHolder(holder: LoadingHelper.ViewHolder) {
        val layoutParams: ViewGroup.LayoutParams = holder.rootView.layoutParams
        layoutParams.height = height
        holder.rootView.layoutParams = layoutParams
    }
}